<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    // test1
    var name1 = "window"
    var obj1 = {
        name1: "obj",
        getName: function () {
            return function () {
                return this.name1
            }
        }
    }
    console.log(obj1.getName()())//window

    // test2
    var name2 = "window"
    var obj2 = {
        name2: "obj",
        getName: function () {
            var that = this //存在闭包
            return function () {
                return that.name2
            }
        }
    }
    console.log(obj2.getName()())//obj

    // test3
    function fun(n, o) { //0 u // 1,0
        console.log(o) // u //
        return {
            fun: function (m) { //
                return fun(m, n);// 0 //
            }
        }
    }
    var a = fun(0);//undefined
    a.fun(1);//0
    a.fun(2);//0
    a.fun(3);//0

    var b = fun(0).fun(1).fun(2).fun(3); //undefined 0

    var c = fun(0).fun(1);
    c.fun(2);
    c.fun(3);


</script>
</body>
</html>